dnl Process this file with autoconf to produce a configure script.


AC_PREREQ(2.61)
AC_INIT([gftp2], [0.1], [freeplant@gmail.com])
AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_HEADER([config.h])


AM_INIT_AUTOMAKE([1.9 foreign])

AM_MAINTAINER_MODE


AC_ARG_ENABLE(ssl, 
              [  --disable-ssl		Disable SSL support], 
              enable_ssl=$enableval, 
              enable_ssl="yes")


# Checks for programs.
AC_PROG_CC
AM_C_PROTOTYPES
AC_C_CONST
AC_PROG_MAKE_SET
AC_PROG_RANLIB

# Checks for headers.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_MAJOR
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h libintl.h limits.h locale.h netdb.h netinet/in.h stdint.h stdlib.h string.h strings.h sys/ioctl.h sys/socket.h sys/time.h termios.h unistd.h utime.h utmp.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_STRUCT_ST_BLOCKS
AC_CHECK_MEMBERS([struct stat.st_rdev])
AC_HEADER_TIME
AC_STRUCT_TM
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_C_VOLATILE

# Checks for library functions.
AC_FUNC_CHOWN
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_FORK
AC_PROG_GCC_TRADITIONAL
AC_FUNC_LSTAT
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_MALLOC
AC_FUNC_MKTIME
AC_FUNC_REALLOC
AC_FUNC_SELECT_ARGTYPES
AC_TYPE_SIGNAL
AC_FUNC_STAT
AC_FUNC_STRFTIME
AC_FUNC_STRTOD
AC_FUNC_UTIME_NULL
AC_INTL_PRINTF
AC_CHECK_FUNCS([alarm dup2 ftruncate getcwd gethostbyname gettimeofday memmove memset mkdir rmdir select setlocale socket strcasecmp strchr strdup strrchr strstr strtol uname utime])


# This is needed by fsplib. This check is from configure.ac in that distribution.
AC_CHECK_TYPE(union semun, ,AC_DEFINE(_SEM_SEMUN_UNDEFINED,1,[Define if you do not have semun in sys/sem.h]),
[#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
])


# Check for gtk libs


GLIB_REQUIRED=2.16.0
GTK_REQUIRED=2.12.0


pkg_modules="gtk+-2.0 >= $GTK_REQUIRED \ 
             glib-2.0 >= $GLIB_REQUIRED \
             gthread-2.0"

PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])
AC_SUBST(PACKAGE_CFLAGS)
AC_SUBST(PACKAGE_LIBS)


SSL_LIBS=""
if test "x$enable_ssl" = "xyes" ; then
	AC_CHECK_HEADERS(openssl/ssl.h ssl.h)

	if test $ac_cv_header_openssl_ssl_h = yes -o $ac_cv_header_ssl_h = yes ; then
		AC_CHECK_LIB(ssl, SSL_library_init, SSL_LIBS="-lcrypto -lssl")

		if test "x$SSL_LIBS" != "x" ; then
			AC_DEFINE(USE_SSL, 1, 
                                  [define if you want to enable SSL support])
		fi
	fi
fi
AC_SUBST(SSL_LIBS)

# For translation
GETTEXT_PACKAGE=gftp2
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.])
AC_PROG_INTLTOOL([0.35])

ALL_LINGUAS="en zh_cn"

AM_GLIB_GNU_GETTEXT

dnl Set PACKAGE_LOCALE_DIR in config.h.
GLIB_DEFINE_LOCALEDIR(PACKAGE_LOCALE_DIR)



AC_CONFIG_FILES(po/Makefile.in
	Makefile
    data/Makefile
    data/icons/Makefile
	lib/Makefile
	lib/fsplib/Makefile
	src/Makefile
)
AC_OUTPUT
